<admintpl file="header" />
<style type="text/css">
	.error_info{
		font-size : 13px;
		color     : red;
	}
	.sucess_info{
		font-size: 13px;
		color    : green;
	}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('Finance/finance_list')}">账单列表</a></li>
			<!-- <li class="active"><a href="{:U('Finance/recharge_log')}">充值记录</a></li>
			<li><a href="{:U('Finance/recharge')}">账户充值</a></li> -->
		</ul>
		<ul class="inline" style="margin-left: 25px;">
			<li style="width:200px;">客户总数量：{$finance_info['customer_count']}</li>
			<li style="width:200px;">充值总金额：￥{:money_number_format($finance_info['recharge_money_sum'])}</li>	
			<li style="width:200px;">消费总金额：￥{:money_number_format($finance_info['charge_money_sum'])}</li>
		</ul>
        <form class="well form-search" method="post" action="{:U('Finance/finance_list',array('type'=>$type,'value'=>$value))}">
            <a class="btn <if condition='$Think.get.type eq 1 AND $Think.get.value eq 1'>btn-danger<else />btn-success</if>" href="{:U('Finance/finance_list',array('type'=>1,'value'=>1,'customer_mobile'=>$mobile))}">今日</a>
            <a class="btn <if condition='$Think.get.type eq 1 AND $Think.get.value eq 2'>btn-danger<else />btn-success</if>" href="{:U('Finance/finance_list',array('type'=>1,'value'=>2,'customer_mobile'=>$mobile))}">昨日</a>
            <a class="btn <if condition='$Think.get.type eq 1 AND $Think.get.value eq 3'>btn-danger<else />btn-success</if>" href="{:U('Finance/finance_list',array('type'=>1,'value'=>3,'customer_mobile'=>$mobile))}">上一周</a>
            <a class="btn <if condition='$Think.get.type eq 1 AND $Think.get.value eq 4'>btn-danger<else />btn-success</if>" href="{:U('Finance/finance_list',array('type'=>1,'value'=>4,'customer_mobile'=>$mobile))}">上一个月</a>
            <a class="btn <if condition='$Think.get.type eq 1 AND $Think.get.value eq 5'>btn-danger<else />btn-success</if>" href="{:U('Finance/finance_list',array('type'=>1,'value'=>5,'customer_mobile'=>$mobile))}">上三个月</a>
               手机号:
            <input type="text" name="customer_mobile" style="width: 150px;" value="{$mobile}" placeholder="用户手机号">
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:U('Finance/finance_list')}">清空</a>

        </form>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th>客户名称</th>
					<th>客户手机号</th>
					<th>总计充值金额</th>
					<th>最后充值日期</th>
					<th>总计消费金额</th>
					<th>最后消费日期</th>
					<th>账户余额</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
		
				<foreach name="list" item="vo">
				<tr>
					<td>{$vo['customer_info']['customer_name']}</td>
					<td>{$vo['customer_info']['mobile']}</td>

				    <td style="text-align:right">{$vo['recharge_money_sum']}</td>
					<td>{$vo['recharge_time_max']}</td>
					<td style="text-align:right">{$vo['charge_money_sum']}</td>
					<td>{$vo['charge_time_max']}</td>
				    <td style="text-align:right">{$vo['customer_info']['money']}</td>
				    <td><a style="cursor: pointer;" href="{:U('Finance/finance_info',array('customer_mobile'=>$vo['customer_mobile']))}">详情</a></td>
				</tr>
				</foreach>
			</tbody>
		</table>

		<div class="pagination">{$page}</div>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
	    //时间控件初始化
	    var now      = new Date();
	    var nowYear  = now.getFullYear() ; //年
	    var nowMonth = now.getMonth()+1<10?"0"+(now.getMonth()+1):now.getMonth(); //月
	    
	    if($("#user_date").val() ==''){
	    	$("#user_date").val(nowYear+'-'+nowMonth);
	    }
        
        $(function(){
        	$("#create-finance").click(function(){

        		var user_date     = $("#user_date").val();
        		var url           = "{:U('Finance/createFinance')}";

        		var user_date_arr = new Array(); //定义一数组 
                    user_date_arr = user_date.split("-"); //字符分割 

               

                $.ajaxSetup({   
                    async : false  
                }); 


        		$.post(url,{year:user_date_arr[0],month:user_date_arr[1]},function(data){
                    if(data.status == '1'){
                        $("#info").text(data.info);
                        $("#info").addClass('sucess_info');
                        window.location.href = data.url;
                    }else if(data.status == '2'){
                    	$("#info").text(data.info);
                        $("#info").addClass('error_info');
                    }else{
                    	$("#info").text('生成失败！');
                    	$("#info").addClass('error_info');
                    }
        		})
        		
        	})
        })

	</script>
</body>
</html>